<?php
/**
 * Created by PhpStorm.
 * User: kkw
 * Date: 2019/1/27
 * Time: 12:37
 */

namespace suda\welcome\response;


use suda\core\Request;
use suda\core\Response;

class VerifyResponse extends Response
{

    public function onRequest(Request $request)
    {

        $this->type('png');
        $im = @imagecreatetruecolor(100, 50) or die("Cannot Initialize new GD image stream");
        // resource 路径
        $path = app()->getModuleResourcePath(module(__FILE__));
        $font = $path.'/ttf/Wildwords_PL.ttf';

        $text_color = imagecolorallocate($im, 233, 14, 91);
        $background_color = imagecolorallocate($im, 255, 255, 255);
        imagefilledrectangle($im, 0, 0, 100, 50, $background_color);

        $text = 'hello';

        imagettftext($im, 20, 0, 11, 21, $text_color, $font, $text);
        imagepng($im);
        imagedestroy($im);
    }
}